//
//  ZYCNoticePushView.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/22.
//

#import "ZYCNoticePushView.h"
@interface ZYCNoticePushView ()
@property (nonatomic, strong) UIView *lineOne;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UIView *lineTwo;
@property (nonatomic, strong) UILabel *contentLabel;
@end

@implementation ZYCNoticePushView

- (void)setTotal:(NSInteger)total{
    _total = total;
    _contentLabel.text = [NSString stringWithFormat:@"%zd人",total];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.iconView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.arrowImageView];
        [self addSubview:self.lineOne];
        [self addSubview:self.lineTwo];
        [self addSubview:self.contentLabel];
        
        self.userInteractionEnabled = YES;
        

        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap:)];
        [self addGestureRecognizer:tap];
        [self.lineOne mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self);
            make.height.mas_equalTo(1);
        }];
        [self.lineTwo mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self);
            make.height.mas_equalTo(1);
        }];
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.centerY.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(14.5, 14.5));
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.equalTo(self.iconView.mas_right).offset(6.5);
        }];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.arrowImageView.mas_left).offset(-11.5f);
            make.centerY.equalTo(self);
        }];
        
        [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.centerY.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(7, 12));
        }];
    }
    return self;
}

- (void)clickTap:(UITapGestureRecognizer *)tap{
    if ([self.delegate respondsToSelector:@selector(noticePushViewDidClick)]) {
        [self.delegate noticePushViewDidClick];
    }
}
- (UIImageView *)iconView {
    if (!_iconView) {
        _iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xr"]];
    }
    return _iconView;
}

- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"jt"]];
    }
    return _arrowImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithString:@"推送范围" Font:kCustomFont(@"PingFangSC-Regular", 16.0f) titleColor:HEX_RGB(@"333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}
- (UIView *)lineOne {
    if (!_lineOne) {
        _lineOne = [[UIView alloc] init];
        _lineOne.backgroundColor = HEX_RGB(@"#EAEAEA");
    }
    return _lineOne;
}
- (UIView *)lineTwo {
    if (!_lineTwo) {
        _lineTwo = [[UIView alloc] init];
        _lineTwo.backgroundColor = HEX_RGB(@"#EAEAEA");
    }
    return _lineTwo;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 16.0f) titleColor:HEX_RGB(@"#009B4C") textAlignment:ZZTextAlignmentLeft];
    }
    return _contentLabel;
}

-(void)dealloc{
    
}
@end
